package simple.demo.springintegration.demo.chapter5.component;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.stereotype.Component;

import simple.demo.springintegration.demo.chapter5.model.Hello;

@Component
public class SimpleHandler {
	private PollableChannel channel;
	
	@Value("#{output2}")
	public void setChannel(PollableChannel channel) {
		this.channel = channel;
	}
	

	@ServiceActivator
	public String handleMessage(Hello message) {
		System.out.println("Hello: " + message);
		channel.send(MessageBuilder.withPayload("Generated : " + message).build());
		return "RECV: " + message;
	}
}
